package org.zhadoop.stream.cql.semanticanalyzer.parser.context;

import java.util.ArrayList;
import java.util.List;

import org.zhadoop.stream.cql.exception.SemanticAnalyzerException;
import org.zhadoop.stream.cql.semanticanalyzer.analyzecontext.expressiondesc.ExpressionDescribe;
import org.zhadoop.stream.cql.semanticanalyzer.parsecontextreplacer.ParseContextReplacer;
import org.zhadoop.stream.cql.semanticanalyzer.parsecontextwalker.ParseContextWalker;

import com.google.common.base.Joiner;

/**
 * in 表达式解析内容
 * 
 * @author zwd
 *
 */
public class ExpressionInContext extends BaseExpressionParseContext {

	private boolean isNot = false;

	private List<BaseExpressionParseContext> expressions;

	public ExpressionInContext() {
		expressions = new ArrayList<BaseExpressionParseContext>();
	}

	public boolean isNot() {
		return isNot;
	}

	public void setNot(boolean isNot) {
		this.isNot = isNot;
	}

	public List<BaseExpressionParseContext> getExpressions() {
		return expressions;
	}

	public void setExpressions(List<BaseExpressionParseContext> expressions) {
		this.expressions = expressions;
	}

	@Override
	public void walkChildAndReplace(ParseContextReplacer replacer) {
		// TODO Auto-generated method stub

	}

	@Override
	protected ExpressionDescribe createExpressionDesc() throws SemanticAnalyzerException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		if (isNot) {
			sb.append(" NOT ");
		}

		sb.append(" IN ");
		sb.append(" ( ");
		sb.append(Joiner.on(", ").join(expressions));
		sb.append(" ) ");
		return sb.toString();
	}

	@Override
	protected void walkChild(ParseContextWalker walker) {
		// TODO Auto-generated method stub

	}

}
